﻿Public Class BasePage
    Inherits System.Web.UI.Page

    ''' <summary>
    ''' get query data
    ''' </summary>
    ''' <param name="paramName">Tên param của query string cần lấy</param>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Protected ReadOnly Property QueryString(paramName As String) As Object
        Get
            If IsNothing(HttpContext.Current.Items("RouteData")) = False Then
                Return DirectCast(HttpContext.Current.Items("RouteData"), Routing.RouteData).Values(paramName)
            Else
                Return Nothing
            End If
        End Get
    End Property

    Protected ReadOnly Property AppSettings(key As String) As Object
        Get
            Return ConfigurationManager.AppSettings(key)
        End Get
    End Property

    Protected Function GetDBAccess() As DBAccess

        Dim xConStr As String
        Dim dataAccess As DBAccess = Nothing

        Try
            xConStr = ConfigurationManager.ConnectionStrings("ConStr").ConnectionString
            If xConStr = String.Empty Then
                Throw New Exception("NO_CONNECTION_STRING")
            End If
            dataAccess = New DBAccess(xConStr)

            Return dataAccess
        Catch ex As Exception
            Throw
        End Try
    End Function
End Class
